home *** CD-ROM | disk | FTP | other *** search
/ One Click 14 / OneClick14.iso / Ferramentas / Convert XLS to Pdf / xls2pdf_setup.exe / {app} / lib / gs_init.ps < prev    next >
Encoding:
Text File  |  2002-11-21  |  62.2 KB  |  1,957 lines

  1. % Copyright (C) 1989-2002 artofcode LLC. All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_init.ps,v 1.74 2002/11/21 07:12:17 raph Exp $
  14. % Initialization file for the interpreter.
  15. % When this is run, systemdict is still writable.
  16.  
  17. % Comment lines of the form
  18. %    %% Replace <n> <file(s)>
  19. % indicate places where the next <n> lines should be replaced by
  20. % the contents of <file(s)>, when creating a single merged init file.
  21.  
  22. % The interpreter can call out to PostScript code.  All procedures
  23. % called in this way, and no other procedures defined in these
  24. % initialization files, have names that begin with %, e.g.,
  25. % (%Type1BuildChar) cvn.
  26.  
  27. % Check the interpreter revision.  NOTE: the interpreter code requires
  28. % that the first non-comment token in this file be an integer.
  29. 800
  30. dup revision ne
  31.  { (gs: Interpreter revision \() print revision 10 string cvs print
  32.    (\) does not match gs_init.ps revision \() print 10 string cvs print
  33.    (\).\n) print flush //null 1 .quit
  34.  }
  35. if pop
  36.  
  37. % Acquire userdict, and set its length if necessary.
  38. /userdict where
  39.  { pop userdict maxlength 0 eq }
  40.  { true }
  41. ifelse
  42. systemdict exch
  43.  {        % userdict wasn't already set up by iinit.c.
  44.    dup /userdict
  45.    currentdict dup 200 .setmaxlength        % userdict
  46.    .forceput            % userdict is local, systemdict is global
  47.  }
  48. if begin
  49.  
  50. % Define dummy local/global operators if needed.
  51. systemdict /.setglobal known
  52.  { true .setglobal
  53.  }
  54.  { /.setglobal { pop } bind def
  55.    /.currentglobal { false } bind def
  56.    /.gcheck { pop false } bind def
  57.  }
  58. ifelse
  59.  
  60. % Define .languagelevel if needed.
  61. systemdict /.languagelevel known not { /.languagelevel 1 def } if
  62.  
  63. % Optionally choose a default paper size other than U.S. letter.
  64. % (a4) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse
  65.  
  66. % Turn on array packing for the rest of initialization.
  67. true setpacking
  68.  
  69. % Define the old MS-DOS EOF character as a no-op.
  70. % This is a hack to get around the absurd habit of MS-DOS editors
  71. % of adding an EOF character at the end of the file.
  72. <1a> cvn { } def
  73.  
  74. % Acquire the debugging flags.
  75. currentdict /DEBUG known   /DEBUG exch def
  76.   /VMDEBUG
  77.     DEBUG {{print mark
  78.             systemdict /level2dict known
  79.          { .currentglobal dup false .setglobal vmstatus
  80.            true .setglobal vmstatus 3 -1 roll pop
  81.            6 -2 roll pop .setglobal
  82.          }
  83.          { vmstatus 3 -1 roll pop
  84.          }
  85.         ifelse usertime 16#fffff and counttomark
  86.           { ( ) print (           ) cvs print }
  87.         repeat pop
  88.         ( ) print systemdict length (    ) cvs print
  89.         ( ) print countdictstack (  ) cvs print
  90.         ( <) print count (    ) cvs print (>\n) print flush
  91.       }}
  92.       {{pop
  93.       }}
  94.      ifelse
  95.   def
  96.  
  97. currentdict /BATCH known   /BATCH exch def
  98. currentdict /DELAYBIND known   /DELAYBIND exch def
  99. currentdict /DISKFONTS known   /DISKFONTS exch def
  100. currentdict /DOINTERPOLATE .knownget { /INTERPOLATE exch def } if
  101. currentdict /ESTACKPRINT known   /ESTACKPRINT exch def
  102. currentdict /FAKEFONTS known   /FAKEFONTS exch def
  103. currentdict /FIXEDMEDIA known   /FIXEDMEDIA exch def
  104. currentdict /FIXEDRESOLUTION known   /FIXEDRESOLUTION exch def
  105. currentdict /LOCALFONTS known   /LOCALFONTS exch def
  106. currentdict /NOBIND known   /NOBIND exch def
  107. /.bind /bind load def
  108. NOBIND { /bind { } def } if
  109. currentdict /NOCACHE known   /NOCACHE exch def
  110. currentdict /NOCCFONTS known   /NOCCFONTS exch def
  111. currentdict /NOCIE known   /NOCIE exch def
  112. currentdict /NODISPLAY known   not /DISPLAYING exch def
  113. currentdict /NOFONTMAP known   /NOFONTMAP exch def
  114. currentdict /NOFONTPATH known   /NOFONTPATH exch def
  115. currentdict /NOGC known   /NOGC exch def
  116. currentdict /NOINTERPOLATE .knownget { /INTERPOLATE exch not def } if
  117. currentdict /NOPAGEPROMPT known   /NOPAGEPROMPT exch def
  118. currentdict /NOPAUSE known   /NOPAUSE exch def
  119. currentdict /NOPLATFONTS known   /NOPLATFONTS exch def
  120. currentdict /NOPROMPT known   /NOPROMPT exch def
  121. currentdict /NOTRANSPARENCY known   /NOTRANSPARENCY exch def
  122. currentdict /DOPS known   /DOPS exch def
  123. % The default value of ORIENT1 is true, not false.
  124. currentdict /ORIENT1 known not { /ORIENT1 true def } if
  125. currentdict /OSTACKPRINT known   /OSTACKPRINT exch def
  126. currentdict /OUTPUTFILE known    % obsolete
  127.  { /OutputFile /OUTPUTFILE load def
  128.    currentdict /OUTPUTFILE .undef
  129.  } if
  130. currentdict /QUIET known   /QUIET exch def
  131. % DELAYSAFER is effectively the same as newer NOSAFER
  132. currentdict /DELAYSAFER known { /DELAYSAFER true def /NOSAFER true def } if
  133. /SAFER currentdict /NOSAFER known {
  134.   false
  135. } {
  136.   currentdict /SAFER known
  137.   currentdict /PARANOIDSAFER known or    % PARANOIDSAFER is equivalent
  138. }
  139. ifelse def
  140. currentdict /SHORTERRORS known   /SHORTERRORS exch def
  141. currentdict /STRICT known   /STRICT exch def
  142. currentdict /TTYPAUSE known   /TTYPAUSE exch def
  143. currentdict /WRITESYSTEMDICT known   /WRITESYSTEMDICT exch def
  144.  
  145. % Acquire environment variables.
  146. currentdict /DEVICE known not
  147.  { (GS_DEVICE) getenv { /DEVICE exch def } if } if
  148.  
  149. (START) VMDEBUG
  150.  
  151. % Open the standard files, so they will be open at the outermost save level.
  152. (%stdin) (r) file pop
  153. (%stdout) (w) file pop
  154. (%stderr) (w) file pop
  155.  
  156. /.currentuserparams where {
  157.   pop mark
  158.     % The Adobe implementations appear to have very large maximum
  159.     % stack sizes.  This turns out to actually make a difference,
  160.     % since some badly-behaved files include extremely long procedures,
  161.     % or construct huge arrays on the operand stack.
  162.     % We reset the stack sizes now so that we don't have to worry
  163.     % about overflowing the (rather small) built-in stack sizes
  164.     % during initialization.
  165.   /MaxDictStack 500
  166.   /MaxExecStack 5000
  167.   /MaxOpStack 50000
  168.   .dicttomark .setuserparams
  169. } if
  170.  
  171. % Define a procedure for skipping over an unneeded section of code.
  172. % This avoids allocating space for the skipped procedures.
  173. % We can't use readline, because that imposes a line length limit.
  174. /.skipeof    % <string> .skipeof -
  175.  { currentfile exch 1 exch .subfiledecode flushfile
  176.  } .bind def
  177.  
  178. % Define procedures to assist users who don't read the documentation.
  179. userdict begin
  180. /help
  181.  { (Enter PostScript commands.  '(filename) run' runs a file, 'quit' exits.\n)
  182.    print flush
  183.  } .bind def
  184. end
  185.  
  186. % Define =string, which is used by some PostScript programs even though
  187. % it isn't documented anywhere.
  188. % Put it in userdict so that each context can have its own copy.
  189. userdict /=string 256 string put
  190.  
  191. % Print the greeting.
  192.  
  193. /printgreeting
  194.  { mark
  195.    product (Ghostscript) search
  196.     { pop pop pop
  197.       (This software comes with NO WARRANTY: see the file PUBLIC for details.\n)
  198.     }
  199.     { pop
  200.     }
  201.    ifelse
  202.    (\n) copyright
  203.    (\)\n) revisiondate 10 mod revisiondate 10 idiv 10 mod (-)
  204.    revisiondate 100 idiv 10 mod revisiondate 1000 idiv 10 mod (-)
  205.    revisiondate 10000 idiv ( \()
  206.    revision 10 mod
  207.    revision 100 mod 10 idiv (.)
  208.    revision 100 idiv ( )
  209.    product
  210.    counttomark
  211.     { (%stdout) (w) file exch 0 .writecvp
  212.     } repeat pop
  213.  } .bind def
  214.  
  215. QUIET not { printgreeting flush } if
  216.  
  217. % Define a special version of def for making operator procedures.
  218. /obind {    % <name> <proc> obind <name> <oper>
  219.   1 index exch .makeoperator
  220. } .bind def
  221. /odef {        % <name> <proc> odef -
  222.   1 index exch .makeoperator def
  223. } .bind def
  224.  
  225. % Define a special version of def for storing local objects into global
  226. % dictionaries.  Like .forceput, this exists only during initialization.
  227. /.forcedef {        % <key> <value> .forcedef -
  228.   currentdict 3 1 roll .forceput
  229. } .bind odef
  230.  
  231. % Define procedures for accessing variables in systemdict and userdict
  232. % regardless of the contents of the dictionary stack.
  233. /.systemvar {        % <name> .systemvar <value>
  234.   //systemdict exch get
  235. } .bind odef
  236. /.userdict {        % - .userdict <dict>
  237.   /userdict .systemvar
  238. } .bind odef
  239. /.uservar {        % <name> .uservar <value>
  240.   .userdict exch get
  241. } .bind odef
  242.  
  243. % If we're delaying binding, remember everything that needs to be bound later.
  244. DELAYBIND NOBIND not and
  245.  { .currentglobal false .setglobal
  246.    systemdict /.delaybind 1500 array .forceput
  247.    .setglobal
  248.    userdict /.delaycount 0 put
  249.     % When we've done the delayed bind, we want to stop saving.
  250.     % Detect this by the disappearance of .delaybind.
  251.    /bind
  252.     { /.delaybind .systemvar dup length 0 ne
  253.        { .delaycount 2 index put
  254.          .userdict /.delaycount .delaycount 1 add put
  255.        }
  256.        { pop .bind
  257.        }
  258.       ifelse
  259.     } .bind def
  260.  } if
  261.  
  262. %**************** BACKWARD COMPATIBILITY ****************
  263. /hwsizedict mark /HWSize //null .dicttomark readonly def
  264. /copyscanlines {        % <device> <y> <string> copyscanlines <substr>
  265.   0 3 1 roll 3 index //hwsizedict .getdeviceparams
  266.   exch pop exch pop aload pop 3 2 roll
  267.   0 exch //null exch .getbitsrect exch pop
  268. } bind odef
  269. currentdict /hwsizedict .undef
  270. /getdeviceprops
  271.  { //null .getdeviceparams
  272.  } bind odef
  273. /.putdeviceprops
  274.  { //null true counttomark 1 add 3 roll .putdeviceparams
  275.    dup type /booleantype ne
  276.     { dup mark eq { /unknown /rangecheck } if
  277.       counttomark 4 add 1 roll cleartomark pop pop pop
  278.       /.putdeviceprops load exch signalerror
  279.     }
  280.    if
  281.  } bind odef
  282. /.currentfilladjust { .currentfilladjust2 pop } bind odef
  283. /.setfilladjust { dup .setfilladjust2 } bind odef
  284. /.writecvs { 0 .writecvp } bind odef
  285. %**************** DEPRECATED PROCEDURES ****************
  286. %**************** DO NOT USE THESE IN NEW CODE ****************
  287. /max { .max } bind def        % use .max instead
  288. /min { .min } bind def        % use .min instead
  289. /unread /.unread load def    % use .peekstring instead
  290. %**************** END OF BACKWARD COMPATIBILITY SECTION ****************
  291.  
  292. % Utility procedure to sort an array
  293. % <array> <lt-proc> .sort <array>
  294. /.sort {
  295.   1 index length 1 sub -1 1 {
  296.     2 index exch 2 copy get 3 copy    % arr proc arr i arr[i] arr i arr[i]
  297.     0 1 3 index 1 sub {
  298.       3 index 1 index get    % arr proc arr i arr[i] arr imax amax j arr[j]
  299.       2 index 1 index 10 index exec {    % ... amax < arr[j]
  300.     4 2 roll
  301.       } if pop pop
  302.     } for            % arr proc arr i arr[i] arr imax amax
  303.     4 -1 roll exch 4 1 roll put put
  304.   } for pop
  305. } bind def
  306.  
  307. % Define predefined procedures substituting for operators,
  308. % in alphabetical order.
  309.  
  310. userdict /#copies 1 put
  311. % Adobe implementations don't accept /[ or /], so we don't either.
  312. ([) cvn
  313.     /mark load def
  314. (]) cvn
  315.     {counttomark array astore exch pop} odef
  316. % .beginpage is redefined if setpagedevice is present.
  317. /.beginpage { } odef
  318. % In LanguageLevel 3, copypage erases the page.
  319. /copypage {
  320.     .languagelevel 3 ge
  321.     dup { 0 } { 1 } ifelse .endpage {
  322.       .currentnumcopies 1 index .outputpage
  323.       (>>copypage, press <return> to continue<<\n) .confirm
  324.       dup { erasepage } if
  325.     } if pop .beginpage
  326. } odef
  327. /currentmatrix {
  328.     .currentmatrix 6 index astore pop
  329. } odef
  330. % .currentnumcopies is redefined in Level 2.
  331. /.currentnumcopies { #copies } odef
  332. /setcolorscreen where { pop        % not in all Level 1 configurations
  333.    /currentcolorscreen
  334.     { .currenthalftone
  335.        { { 60 exch 0 exch 3 copy 6 copy }    % halftone - not possible
  336.          { 3 copy 6 copy }            % screen
  337.          { }                % colorscreen
  338.        }
  339.       exch get exec
  340.     } odef
  341. } if
  342. /currentscreen
  343.     { .currenthalftone
  344.        { { 60 exch 0 exch }            % halftone - not possible
  345.          { }                % screen
  346.          { 12 3 roll 9 { pop } repeat }    % colorscreen
  347.        }
  348.       exch get exec
  349.     } odef
  350. /.echo /echo load def
  351. userdict /.echo.mode true put
  352. /echo    {dup /.echo.mode exch store .echo} odef
  353. /.eexec_param_dict mark
  354.   /eexec true
  355.   /seed 55665
  356. .dicttomark readonly def
  357. /eexec {
  358.     % Rebind .currentresourcefile if it is the source for the eexec.
  359.   dup //.eexec_param_dict //filterdict /eexecDecode get exec
  360.   cvx exch .currentresourcefile eq
  361.   //systemdict begin { {exec} .execasresource } { exec } ifelse
  362.     % Only pop systemdict if it is still the top element,
  363.     % because this is apparently what Adobe interpreters do.
  364.   currentdict //systemdict eq { end } if
  365. } odef
  366. % .endpage is redefined if setpagedevice is present.
  367. /.endpage { 2 ne } odef
  368. % erasepage mustn't use gsave/grestore, because we call it before
  369. % the graphics state stack has been fully initialized.
  370. /erasepage
  371.     { /currentcolor where
  372.        { pop currentcolor currentcolorspace { setcolorspace setcolor } }
  373.        { /currentcmykcolor where
  374.           { pop currentcmykcolor { setcmykcolor } }
  375.           { currentrgbcolor { setrgbcolor } }
  376.          ifelse
  377.        }
  378.       ifelse
  379.           currentoverprint false setoverprint 1 setgray .fillpage setoverprint
  380.           exec
  381.     } odef
  382. % To satisfy the Genoa FTS, executive must be a procedure, not an operator.
  383. /executive
  384.     { { prompt
  385.          { (%statementedit) (r) file } stopped
  386.          { pop pop $error /errorname get /undefinedfilename eq
  387.         { .clearerror exit } if        % EOF
  388.            handleerror //null        % ioerror??
  389.          }
  390.         if
  391.         cvx { .runexec } execute
  392.       } loop
  393.     } bind def
  394. /filter
  395.     { //filterdict 1 index .knownget
  396.        { exch pop exec }
  397.        { /filter load /undefined signalerror }
  398.       ifelse
  399.     } odef
  400. /handleerror
  401.     { /errordict .systemvar /handleerror get exec } bind def
  402. /identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def
  403. /identmatrix
  404.     { dup 0 //identmatrix putinterval } odef
  405. /languagelevel 1 def        % gs_lev2.ps may change this
  406. /makeimagedevice { false makewordimagedevice } odef
  407. /matrix    { 6 array identmatrix } odef
  408. /pathbbox
  409.     { false .pathbbox
  410.     } odef
  411. % .promptmsg is redefined if the interpreter includes readline support.
  412. /.promptmsg {
  413.     (GS) print
  414.     count 0 ne { (<) print count =only } if
  415.     (>) print flush
  416. } bind def
  417. /prompt    { flush flushpage NOPROMPT not { .promptmsg } if } bind def
  418. /pstack    { 0 1 count 3 sub { index == } for } bind def
  419. /putdeviceprops
  420.     { .putdeviceprops { erasepage } if } odef
  421. /quit    { /quit load 0 .quit } odef
  422. /run    { dup type /filetype ne { (r) file } if
  423.         % We must close the file when execution terminates,
  424.         % regardless of the state of the stack,
  425.         % and then propagate an error, if any.
  426.       cvx .runexec
  427.     } odef
  428. % Execute a file.
  429. % Level 2 uses 2 .stop to clear the e-stack for a successful startjob:
  430. % we detect that here, since we need to handle this even if we start out
  431. % without job control in effect.
  432. %
  433. % What we push on the e-stack is the following to be executed in this order:
  434. %    <lit-file|fileproc> .runexec1 <lit-file|fileproc> .runexec2
  435. /.runexec1 {        % <file|fileproc> .runexec1 -
  436.   dup type /filetype ne { cvx exec } if
  437.   cvx //null 2 .stopped
  438.     % If we got back here from a startjob, just keep going.
  439.     % startjob replaces the null on the o-stack with a procedure
  440.     % to be executed when we get back here.
  441.   dup //null ne { exec true } { pop false } ifelse
  442. } bind def
  443. /.runexec2 {        % <continue> <file|fileproc> .runexec2 -
  444.   exch {
  445.     .runexec
  446.   } {
  447.     dup type /filetype ne { cvx exec } if
  448.     closefile
  449.   } ifelse
  450. } bind def
  451. /.runexec {        % <file|fileproc> .runexec -
  452.   cvlit /.runexec1 cvx 1 index /.runexec2 cvx 4 .execn
  453. } bind def
  454. % The following is only for compatibility with Adobe interpreters.
  455. /setdash {
  456.     1 index length 11 gt { /setdash load /limitcheck signalerror } if
  457.     //setdash
  458. } odef
  459. /setdevice
  460.   {
  461.     .setdevice
  462.       {
  463.         mark
  464.           {         % Reset the halftone since the device may differ
  465.             currenthalftone
  466.             dup type /dicttype eq
  467.               { sethalftone }
  468.               { pop }
  469.             ifelse
  470.           }
  471.         stopped
  472.         cleartomark
  473.         erasepage
  474.       }
  475.     if
  476.   }
  477. odef
  478. /setlinecap {
  479.     dup 2 gt { /setlinecap load /rangecheck signalerror } if
  480.     .setlinecap
  481. } odef
  482. /setlinejoin {
  483.     dup 2 gt { /setlinejoin load /rangecheck signalerror } if
  484.     .setlinejoin
  485. } odef
  486. /setmatrix {
  487.     dup aload pop .setmatrix pop
  488. } odef
  489. /showpage {
  490.     0 .endpage .doneshowpage {
  491.       .currentnumcopies true .outputpage
  492.       (>>showpage, press <return> to continue<<\n) .confirm
  493.       initgraphics
  494.           currentoverprint false setoverprint 1 setcolor
  495.           .fillpage
  496.           setoverprint 0 setcolor
  497.     }
  498.     { initgraphics } ifelse .beginpage
  499. } odef
  500. % Code output by Adobe Illustrator relies on the fact that
  501. % `stack' is a procedure, not an operator!!!
  502. /stack    { 0 1 count 3 sub { index = } for } bind def
  503. /start    { BATCH { //null 0 .quit } { executive } ifelse } def
  504. % Internal uses of stopped that aren't going to do a stop if an error occurs
  505. % should use .internalstopped to avoid setting newerror et al.
  506. /.internalstopped { //null 1 .stopped //null ne } bind def
  507. /store {    % Don't alter operands before completing.
  508.     1 index where { 2 index 2 index put pop pop } { def } ifelse
  509. } odef
  510. /.typenames mark .typenames counttomark packedarray exch pop def
  511. /type {
  512.     //.typenames .type
  513. } odef
  514. currentdict /.typenames .undef
  515. % When running in Level 1 mode, this interpreter is supposed to be
  516. % compatible with PostScript "version" 54.0 (I think).
  517. /version (54.0) readonly def
  518. /.wheredict 10 dict def
  519. /.where /where load def
  520. /where {
  521.     //.wheredict 1 index .knownget { exec } { .where } ifelse
  522. } odef
  523.  
  524. % internaldict is defined in systemdict, but the dictionary is allocated
  525. % in local VM.  However, the procedure must be global, since it is an
  526. % "operator" and must be bind-able into global procedures.
  527. % We make a procedure for creating it, since we must create a new one
  528. % for each context with private local VM.
  529. /.makeinternaldict {
  530.   .currentglobal true .setglobal
  531.     [ /dup .systemvar 1183615869 /eq .systemvar
  532.     [ /pop .systemvar //null ] cvx
  533.     false .setglobal
  534.     dup 1 10 dict .forceput    % proc is global, dict is local
  535.     true .setglobal
  536.     [ /internaldict /cvx .systemvar /invalidaccess /signalerror cvx ] cvx
  537.       /ifelse .systemvar
  538.     ] cvx executeonly
  539.   exch .setglobal
  540. } odef
  541. systemdict /internaldict dup .makeinternaldict .makeoperator
  542. .forceput        % proc is local, systemdict is global
  543. % Move superexec to internaldict if superexec is defined.
  544. currentdict /superexec .knownget {
  545.   1183615869 internaldict /superexec 3 -1 roll put
  546.   currentdict /superexec .undef
  547. } if
  548.  
  549. % Define some additional built-in procedures (beyond the ones defined by
  550. % the PostScript Language Reference Manual).
  551. % Warning: these are not guaranteed to stay the same from one release
  552. % to the next!
  553. /concatstrings    %    (str1) (str2) concatstrings (str1str2)
  554.     { exch dup length 2 index length add string    % str2 str1 new
  555.       dup dup 4 2 roll copy        % str2 new new new1
  556.       length 4 -1 roll putinterval
  557.     } bind def
  558. /copyarray
  559.     { dup length array copy } bind def
  560. % Copy a dictionary per the Level 2 spec even in Level 1.
  561. /.copydict        % <fromdict> <todict> .copydict <todict>
  562.     { dup 3 -1 roll { put dup } forall pop } bind def
  563. /copystring
  564.     { dup length string copy } bind def
  565. /findlibfile {
  566.     .libfile { dup .filename pop exch true } { false } ifelse
  567. } odef
  568. /.growdictlength    % get size for growing a dictionary
  569.     { length 3 mul 2 idiv 1 add
  570.     } bind def
  571. /.growdict        % grow a dictionary
  572.     { dup .growdictlength .setmaxlength
  573.     } bind def
  574. /.growput        % put, grow the dictionary if needed
  575.     { 2 index length 3 index maxlength eq
  576.        { 3 copy pop known not { 2 index .growdict } if
  577.        } if
  578.       put
  579.     } bind def
  580. % .localvmarray may be an operator: see zsysvm.c.
  581. /.localvmarray where {
  582.   pop
  583. } {
  584.   /.localvmarray {
  585.     .currentglobal false .setglobal
  586.     exch array exch .setglobal
  587.   } bind def
  588. } ifelse
  589. /.localvmdict where {
  590.   pop
  591. } {
  592.   /.localvmdict {
  593.     .currentglobal false .setglobal
  594.     exch dict exch .setglobal
  595.   } bind def
  596. } ifelse
  597. /.packtomark
  598.     { counttomark packedarray exch pop } bind def
  599. /ppstack
  600.     { 0 1 count 3 sub { index === } for } bind def
  601. /runlibfile
  602.     {        % We don't want to bind 'run' into this procedure,
  603.             % since run may get redefined.
  604.       findlibfile
  605.        { exch pop /run .systemvar exec }
  606.        { /undefinedfilename signalerror }
  607.       ifelse
  608.     } bind def
  609. /selectdevice
  610.     { finddevice setdevice .setdefaultscreen } bind def
  611. /signalerror        % <object> <errorname> signalerror -
  612.     { /errordict .systemvar exch get exec } bind def
  613.  
  614. % Define the =[only] procedures.  Also define =print,
  615. % which is used by some PostScript programs even though
  616. % it isn't documented anywhere.
  617. /write=only {
  618.     .writecvs
  619. } bind def
  620. /write= {
  621.     1 index exch write=only (\n) writestring
  622. } bind def
  623. /=only    { (%stdout) (w) file exch write=only } bind def
  624. /=    { =only (\n) print } bind def
  625. /=print    /=only load def
  626. % Temporarily define == as = for the sake of runlibfile0.
  627. /== /= load def
  628.  
  629. % The following procedures are documented.
  630. /copydevice {        % <device> copydevice <newdevice>
  631.   false .copydevice2
  632. } odef
  633. /finddevice {        % <devicename> finddevice <device>
  634.   /devicedict .systemvar exch get
  635.   dup 1 get //null eq {
  636.         % This is the first request for this type of device.
  637.         % Create a default instance now.
  638.         % Stack: [proto null]
  639.     .currentglobal true .setglobal exch
  640.     dup dup 0 get copydevice 1 exch put
  641.     exch .setglobal
  642.   } if 1 get
  643. } bind def
  644. /findprotodevice {    % <devicename> findprotodevice <protodevice>
  645.   /devicedict .systemvar exch get 0 get
  646. } bind def
  647.  
  648. % Run a resource file.  This allows us to distinguish resource objects
  649. % from objects coming from input files.
  650. userdict /.currentresourcefile //null put
  651. /.execasresource {    % <file> <proc|runfile> .execasresource -
  652.   /stopped .systemvar
  653.   /.currentresourcefile .uservar
  654.         % Stack: file proc -stopped- currfile
  655.   .userdict /.currentresourcefile 5 index cvlit put
  656.   2 .execn        % stopped <file>
  657.   .userdict /.currentresourcefile 3 -1 roll put
  658.   { stop } if
  659. } bind def
  660. /.runresource {        % <file> .runresource -
  661.   { /run .systemvar exec } .execasresource
  662. } bind def
  663.  
  664. % Define procedures for getting and setting the current device resolution.
  665.  
  666. /gsgetdeviceprop    % <device> <propname> gsgetdeviceprop <value>
  667.  { 2 copy mark exch //null .dicttomark .getdeviceparams
  668.    dup mark eq        % if true, not found
  669.     { pop dup /undefined signalerror }
  670.     { 5 1 roll pop pop pop pop }
  671.    ifelse
  672.  } bind def
  673. /gscurrentresolution    % - gscurrentresolution <[xres yres]>
  674.  { currentdevice /HWResolution gsgetdeviceprop
  675.  } bind def
  676. /gssetresolution    % <[xres yres]> gssetresolution -
  677.  { 2 array astore mark exch /HWResolution exch
  678.    currentdevice copydevice putdeviceprops setdevice
  679.  } bind def
  680.  
  681. % Define auxiliary procedures needed for the above.
  682. /shellarguments        % -> shell_arguments true (or) false
  683.     { /ARGUMENTS where
  684.        { /ARGUMENTS get dup type /arraytype eq
  685.           { aload pop /ARGUMENTS //null store true }
  686.           { pop false }
  687.          ifelse }
  688.        { false } ifelse
  689.     } bind def
  690. /.confirm {
  691.   DISPLAYING NOPAUSE not TTYPAUSE or and {
  692.     % Print a message (unless NOPAGEPROMPT or NOPROMPT is true)
  693.     % and wait for the user to type something.
  694.     % If the user just types a newline, flush it.
  695.     NOPAGEPROMPT NOPROMPT or { pop } { print flush } ifelse
  696.     .confirmread
  697.   } {
  698.     pop
  699.   } ifelse
  700. } bind def
  701. /.confirmread {
  702.   TTYPAUSE {
  703.     (/dev/tty) (r) file dup read pop pop closefile
  704.   } {
  705.     .echo.mode false echo
  706.     (%stdin) (r) file dup read {
  707.       dup (\n) 0 get eq { pop pop } { unread } ifelse
  708.     } {
  709.       pop
  710.     } ifelse echo
  711.   } ifelse
  712. } bind def
  713.  
  714. % Define the procedure used by .runfile, .runstdin and .runstring
  715. % for executing user input.
  716. % This is called with a procedure or executable file on the operand stack.
  717. /.execute {        % <obj> .execute <stopped>
  718.   stopped $error /newerror get and
  719.    { handleerror flush true } { false } ifelse
  720. } bind def
  721. /execute {        % <obj> execute -
  722.   .execute pop
  723. } odef
  724. % Define an execute analogue of runlibfile0.
  725. /execute0 {        % <obj> execute0 -
  726.   .execute { /execute0 cvx 1 .quit } if
  727. } bind def
  728. % Define the procedure that the C code uses for running files
  729. % named on the command line.
  730. /.runfile {
  731.   { runlibfile } execute0
  732. } def
  733. % Define the procedure that the C code uses for running piped input.
  734. % We don't use the obvious { (%stdin) run }, because we want the file to be
  735. % reopened if a startjob does a restore.
  736. /.runstdin {
  737.   { { (%stdin) (r) file cvx } .runexec } execute0
  738. } bind def
  739. % Define the procedure that the C code uses for running commands
  740. % given on the command line with -c.  We turn the string into a file so that
  741. % .runexec can do the right thing with a startjob.
  742. /.runstring {
  743.   .currentglobal exch true .setglobal
  744.   0 () .subfiledecode
  745.   exch .setglobal cvx { .runexec } execute0
  746. } bind def
  747. % Define the procedure that the C code uses to set up for executing
  748. % a string that may be received in pieces.
  749. /.runstringbegin {
  750.   .currentglobal true .setglobal
  751.   { .needinput } bind 0 () .subfiledecode
  752.   exch .setglobal cvx .runexec
  753. } bind def
  754.  
  755. % Define a special version of runlibfile that aborts on errors.
  756. /runlibfile0
  757.     { cvlit dup /.currentfilename exch def
  758.        { findlibfile not { stop } if }
  759.       stopped
  760.        { (Can't find \(or open\) initialization file ) print
  761.          .currentfilename == flush /runlibfile0 cvx 1 .quit
  762.        } if
  763.       exch pop cvx stopped
  764.        { (While reading ) print .currentfilename print (:\n) print flush
  765.          handleerror /runlibfile0 1 .quit
  766.        } if
  767.     } bind def
  768. % Temporarily substitute it for the real runlibfile.
  769. /.runlibfile /runlibfile load def
  770. /runlibfile /runlibfile0 load def
  771.  
  772. % Create the error handling machinery.
  773. % Define the standard error handlers.
  774. % The interpreter has created the ErrorNames array.
  775. /.unstoppederrorhandler    % <command> <errorname> .unstoppederrorhandler -
  776.  {    % This is the handler that gets used for recursive errors,
  777.     % or errors outside the scope of a 'stopped'.
  778.    2 copy SHORTERRORS
  779.     { (%%[ Error: ) print =only flush
  780.       (; OffendingCommand: ) print =only ( ]%%) =
  781.     }
  782.     { (Unrecoverable error: ) print =only flush
  783.       ( in ) print = flush
  784.       count 2 gt
  785.        { (Operand stack:\n  ) print
  786.          count 1 sub -1 2 { (  ) print index =only flush } for
  787.      () = flush
  788.        } if
  789.     }
  790.    ifelse
  791.    -1 0 1 //ErrorNames length 1 sub
  792.     { dup //ErrorNames exch get 3 index eq
  793.        { not exch pop exit } { pop } ifelse
  794.     }
  795.    for exch pop .quit
  796.  } bind def
  797. /.errorhandler        % <command> <errorname> .errorhandler -
  798.   {        % Detect an internal 'stopped'.
  799.     1 .instopped { //null eq { pop pop stop } if } if
  800.     $error /.inerror get 1 .instopped { pop } { pop true } ifelse
  801.      { .unstoppederrorhandler
  802.      } if    % detect error recursion
  803.     $error /globalmode .currentglobal false .setglobal put
  804.     $error /.inerror true put
  805.     $error /newerror true put
  806.     $error exch /errorname exch put
  807.     $error exch /command exch put
  808.     $error /recordstacks get $error /errorname get /VMerror ne and
  809.      {        % Attempt to store the stack contents atomically.
  810.        count array astore dup $error /ostack 4 -1 roll
  811.        countexecstack array execstack $error /estack 3 -1 roll
  812.        countdictstack array dictstack $error /dstack 3 -1 roll
  813.        put put put aload pop
  814.      }
  815.      { $error /dstack .undef
  816.        $error /estack .undef
  817.        $error /ostack .undef
  818.      }
  819.     ifelse
  820.     $error /position currentfile status
  821.      { currentfile { fileposition } .internalstopped { pop //null } if
  822.      }
  823.      {        % If this was a scanner error, the file is no longer current,
  824.         % but the command holds the file, which may still be open.
  825.        $error /command get dup type /filetype eq
  826.         { { fileposition } .internalstopped { pop //null } if }
  827.         { pop //null }
  828.        ifelse
  829.      }
  830.     ifelse put
  831.         % During initialization, we don't reset the allocation
  832.         % mode on errors.
  833.     $error /globalmode get $error /.nosetlocal get and .setglobal
  834.     $error /.inerror false put
  835.     stop
  836.   } bind def
  837. % Define the standard handleerror.  We break out the printing procedure
  838. % (.printerror) so that it can be extended for binary output
  839. % if the Level 2 facilities are present.
  840.   /.printerror
  841.    { $error begin
  842.        /command load errorname SHORTERRORS
  843.     { (%%[ Error: ) print =only flush
  844.       (; OffendingCommand: ) print =only
  845.       errorinfo dup //null eq {
  846.         pop
  847.       } {
  848.         (;\nErrorInfo:) print
  849.         dup type /arraytype eq
  850.           { { ( ) print =only } forall }
  851.           { ( ) print =only }
  852.         ifelse
  853.       } ifelse
  854.           ( ]%%) = flush
  855.     }
  856.     { (Error: ) print ==only flush
  857.       ( in ) print ==only flush
  858.       errorinfo dup //null eq {
  859.         pop
  860.       } {
  861.         (\nAdditional information: ) print ==only flush
  862.       } ifelse
  863.       .printerror_long
  864.     }
  865.        ifelse
  866.        .clearerror
  867.      end
  868.      flush
  869.     } bind def     
  870.   /.printerror_long            % long error printout,
  871.                     % $error is on the dict stack
  872.    {    % Push the (anonymous) stack printing procedure.
  873.     %  <heading> <==flag> <override-name> <stackname> proc
  874.        {
  875.      currentdict exch .knownget    % stackname defined in $error?
  876.      {
  877.        4 1 roll            % stack: <stack> <head> <==flag> <over>
  878.        errordict exch .knownget    % overridename defined?
  879.        { 
  880.          exch pop exch pop exec    % call override with <stack>
  881.        }
  882.        { 
  883.          exch print exch        % print heading. stack <==flag> <stack>
  884.          1 index not { () = } if
  885.          { 1 index { (\n    ) } { (   ) } ifelse print
  886.            dup type /dicttype eq
  887.            {
  888.          (--dict:) print
  889.          dup rcheck {
  890.            dup length =only (/) print dup maxlength =only
  891.            dup wcheck not { ((ro)) print } if
  892.          } if
  893.          /gcheck where {
  894.            pop gcheck { ((G)) } { ((L)) } ifelse print
  895.          } {
  896.            pop
  897.          } ifelse (--) print
  898.            }
  899.            {
  900.          dup type /stringtype eq 2 index or
  901.          { ==only } { =only } ifelse
  902.            } ifelse
  903.          } forall
  904.          pop
  905.        }
  906.        ifelse            % overridden
  907.      }
  908.      { pop pop pop
  909.      }
  910.      ifelse                % stack known
  911.        }
  912.  
  913.        (\nOperand stack:) OSTACKPRINT /.printostack /ostack 4 index exec
  914.        (\nExecution stack:) ESTACKPRINT /.printestack /estack 4 index exec
  915.        (\nBacktrace:) true /.printbacktrace /backtrace 4 index exec
  916.        (\nDictionary stack:) false /.printdstack /dstack 4 index exec
  917.        () =
  918.        pop    % printing procedure
  919.  
  920.        errorname /VMerror eq
  921.     { (VM status:) print mark vmstatus
  922.       counttomark { ( ) print counttomark -1 roll dup =only } repeat
  923.       cleartomark () =
  924.     } if
  925.  
  926.        .languagelevel 2 ge
  927.     { (Current allocation mode is ) print
  928.       globalmode { (global\n) } { (local\n) } ifelse print
  929.     } if
  930.  
  931.        .oserrno dup 0 ne
  932.     { (Last OS error: ) print
  933.       errorname /VMerror ne
  934.        { dup .oserrorstring { = pop } { = } ifelse }
  935.        { = }
  936.       ifelse
  937.     }
  938.     { pop
  939.     }
  940.        ifelse
  941.  
  942.        position //null ne
  943.     { (Current file position is ) print position = }
  944.        if
  945.  
  946.    } bind def
  947. % Define a procedure for clearing the error indication.
  948. /.clearerror
  949.  { $error /newerror false put
  950.    $error /errorname //null put
  951.    $error /errorinfo //null put
  952.    0 .setoserrno
  953.  } bind def
  954.  
  955. % Define $error.  This must be in local VM.
  956. .currentglobal false .setglobal
  957. /$error 40 dict .forcedef    % $error is local, systemdict is global
  958.         % newerror, errorname, command, errorinfo,
  959.         % ostack, estack, dstack, recordstacks,
  960.         % binary, globalmode,
  961.         % .inerror, .nosetlocal, position,
  962.         % plus extra space for badly designed error handers.
  963. $error begin
  964.   /newerror false def
  965.   /recordstacks true def
  966.   /binary false def
  967.   /globalmode .currentglobal def
  968.   /.inerror false def
  969.   /.nosetlocal true def
  970.   /position //null def
  971. end
  972. % Define errordict similarly.  It has one entry per error name,
  973. %   plus handleerror.  However, some astonishingly badly written PostScript
  974. %   files require it to have at least one empty slot.
  975. /errordict ErrorNames length 2 add dict
  976. .forcedef        % errordict is local, systemdict is global
  977. .setglobal        % contents of errordict are global
  978. errordict begin
  979.   ErrorNames
  980.    { mark 1 index systemdict /.errorhandler get /exec load .packtomark cvx def
  981.    } forall
  982. % The handlers for interrupt and timeout are special; there is no
  983. % 'current object', so they push their own name.
  984.    { /interrupt /timeout }
  985.    { mark 1 index dup systemdict /.errorhandler get /exec load .packtomark cvx def
  986.    } forall
  987. /handleerror
  988.  { /.printerror .systemvar exec
  989.  } bind def
  990. end
  991.  
  992. % Define the [write]==[only] procedures.
  993. /.dict 8 dict dup
  994. begin def
  995.   /.cvp {1 index exch 1 .writecvp} bind def
  996.   /.p {1 index exch writestring} bind def
  997.   /.p1 {2 index exch writestring} bind def
  998.   /.p2 {3 index exch writestring} bind def
  999.   /.print
  1000.     { dup type .dict exch .knownget { exec } { .cvp } ifelse
  1001.     } bind def
  1002.   /arraytype
  1003.     {dup rcheck
  1004.       {() exch dup xcheck
  1005.         {({) .p2
  1006.          {exch .p1
  1007.           1 index exch .print pop ( )} forall
  1008.          (})}
  1009.         {([) .p2
  1010.          {exch .p1
  1011.           1 index exch .print pop ( )} forall
  1012.          (])}
  1013.        ifelse exch pop .p}
  1014.       {.cvp}
  1015.      ifelse} bind def
  1016.   /packedarraytype /arraytype load def
  1017. {//.dict begin .print pop end}
  1018.   bind
  1019. end
  1020.  
  1021. /write==only exch def
  1022. /write== {1 index exch write==only (\n) writestring} bind def
  1023. /==only { (%stdout) (w) file exch write==only } bind def
  1024. /== {==only (\n) print} bind def
  1025.  
  1026. % Define [write]===[only], an extension that prints dictionaries
  1027. % in readable form and doesn't truncate strings.
  1028. /.dict /write==only load 0 get dup length 2 add dict .copydict dup
  1029. begin def
  1030.   /dicttype
  1031.     { dup rcheck
  1032.        { (<< ) .p1
  1033.           { 2 index 3 -1 roll .print pop ( ) .p1
  1034.         1 index exch .print pop ( ) .p
  1035.           }
  1036.          forall (>>) .p
  1037.        }
  1038.        { .cvp
  1039.        }
  1040.       ifelse
  1041.     } bind def
  1042.   /stringtype
  1043.     { 1 index exch 2 .writecvp
  1044.     } bind def
  1045.  
  1046. {//.dict begin .print pop end}
  1047.   bind
  1048. end
  1049.  
  1050. /write===only exch def
  1051. /write=== {1 index exch write===only (\n) writestring} bind def
  1052. /===only { (%stdout) (w) file exch write===only } bind def
  1053. /=== { ===only (\n) print } bind def
  1054.  
  1055. (END PROCS) VMDEBUG
  1056.  
  1057. % Define the font directory.
  1058. /FontDirectory false .setglobal 100 dict true .setglobal
  1059. .forcedef        % FontDirectory is local, systemdict is global
  1060.  
  1061. % Define the encoding dictionary.
  1062. /EncodingDirectory 16 dict def    % enough for Level 2 + PDF standard encodings
  1063.  
  1064. % Define .findencoding.  (This is redefined in Level 2.)
  1065. /.findencoding
  1066.  { //EncodingDirectory exch get exec
  1067.  } bind def
  1068. /.defineencoding
  1069.  { //EncodingDirectory 3 1 roll put
  1070.  } bind def
  1071. % If we've got the composite font extensions, define findencoding.
  1072. % To satisfy the Genoa FTS, findencoding must be a procedure, not an operator.
  1073. /rootfont where { pop /findencoding { .findencoding } def } if
  1074.  
  1075. % Define .registerencoding.
  1076. % NOTE: This procedure no longer does anything, but it must continue to
  1077. % exist for the sake of toolbin/encs2c.ps.
  1078. /.registerencoding {    % <index> <array> .registerencoding -
  1079.   pop pop
  1080. } bind odef
  1081.  
  1082. % Load StandardEncoding.
  1083. %% Replace 1 (gs_std_e.ps)
  1084. (gs_std_e.ps) dup runlibfile VMDEBUG
  1085.  
  1086. % Load ISOLatin1Encoding.
  1087. %% Replace 1 (gs_il1_e.ps)
  1088. (gs_il1_e.ps) dup runlibfile VMDEBUG
  1089.  
  1090. % Define stubs for the Symbol and Dingbats encodings.
  1091. % Note that the first element of the procedure must be the file name,
  1092. % since gs_lev2.ps extracts it to set up the Encoding resource category.
  1093.  
  1094.   /SymbolEncoding { /SymbolEncoding .findencoding } bind def
  1095. %% Replace 3 (gs_sym_e.ps)
  1096.   EncodingDirectory /SymbolEncoding
  1097.    { (gs_sym_e.ps) //systemdict begin runlibfile SymbolEncoding end }
  1098.   bind put
  1099.  
  1100.   /DingbatsEncoding { /DingbatsEncoding .findencoding } bind def
  1101. %% Replace 3 (gs_dbt_e.ps)
  1102.   EncodingDirectory /DingbatsEncoding
  1103.    { (gs_dbt_e.ps) //systemdict begin runlibfile DingbatsEncoding end }
  1104.   bind put
  1105.  
  1106. (END FONTDIR/ENCS) VMDEBUG
  1107.  
  1108. % Construct a dictionary of all available devices.
  1109. % These are (read-only) device prototypes that can't be
  1110. % installed or have their parameters changed.  For this reason,
  1111. % the value in the dictionary is actually a 2-element writable array,
  1112. % to allow us to create a default instance of the prototype on demand.
  1113.  
  1114.     % Loop until the .getdevice gets a rangecheck.
  1115. errordict /rangecheck 2 copy get
  1116. errordict /rangecheck { pop stop } put    % pop the command
  1117.   0 { {dup .getdevice exch 1 add} loop} .internalstopped pop
  1118.   1 add dict  /devicedict 1 index def
  1119.   begin            % 2nd copy of count is on stack
  1120.    { dup .devicename exch
  1121.      dup wcheck { dup } { //null } ifelse 2 array astore def
  1122.    } repeat
  1123.   end
  1124. put        % errordict /rangecheck
  1125. .clearerror
  1126. /devicenames devicedict { pop } forall devicedict length packedarray def
  1127.  
  1128. % Determine the default device.
  1129. /defaultdevice DISPLAYING
  1130.  { systemdict /DEVICE .knownget
  1131.     { devicedict 1 index known not
  1132.        { (Unknown device: ) print =
  1133.      flush /defaultdevice cvx 1 .quit
  1134.        }
  1135.       if
  1136.     }
  1137.     { 0 .getdevice .devicename
  1138.     }
  1139.    ifelse
  1140.  }
  1141.  { /nullpage
  1142.  }
  1143. ifelse
  1144. /.defaultdevicename 1 index def
  1145. finddevice    % make a copy
  1146. def
  1147. devicedict /Default devicedict .defaultdevicename get put
  1148.  
  1149. (END DEVS) VMDEBUG
  1150.  
  1151. % Define statusdict, for the benefit of programs
  1152. % that think they are running on a LaserWriter or similar printer.
  1153. %% Replace 1 (gs_statd.ps)
  1154. (gs_statd.ps) runlibfile
  1155.  
  1156. (END STATD) VMDEBUG
  1157.  
  1158. % Load the standard font environment.
  1159. %% Replace 1 (gs_fonts.ps)
  1160. (gs_fonts.ps) runlibfile
  1161.  
  1162. (END GS_FONTS) VMDEBUG
  1163.  
  1164. % Define the default halftone screen and BG/UCR functions now, so that
  1165. % it will bind in the original definitions of set[color]screen.
  1166. % We make this a procedure so we can call it again when switching devices.
  1167.  
  1168. % Use an ordered dither for low-resolution devices.
  1169. /.setloreshalftone {    % <dpi> .setloreshalftone -
  1170.     % The following 'ordered dither' spot function was contributed by
  1171.     % Gregg Townsend.  Thanks, Gregg!
  1172.    16.001 div 0            % not 16: avoids rounding problems
  1173.     { 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add <
  1174.     0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4
  1175.     CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64
  1176.     3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94
  1177.     FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54
  1178.     01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB
  1179.     C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B
  1180.     31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B
  1181.     F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B
  1182.     0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7
  1183.     CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67
  1184.     3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97
  1185.     FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57
  1186.     02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8
  1187.     C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68
  1188.     32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98
  1189.     F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58
  1190.      > exch get 256 div
  1191.     }
  1192.    bind
  1193.         % Use correct, per-plane screens for CMYK devices only.
  1194.    //systemdict /setcolorscreen known processcolors 4 eq and
  1195.     { 3 copy 6 copy //setcolorscreen }
  1196.     { //setscreen }
  1197.    ifelse
  1198. } bind def
  1199. /.setloresscreen {    % <dpi> .setloresscreen -
  1200.   .setloreshalftone
  1201.   0 array cvx settransfer    % Genoa CET won't accept a packed array!
  1202.   /setstrokeadjust where { pop true setstrokeadjust } if
  1203. } bind def
  1204. % Use a 45-degree spot screen for high-resolution devices.
  1205. /.sethireshalftone {    % <dpi> .sethireshalftone <doscreen>
  1206.     % According to information published by Hewlett-Packard,
  1207.     % they use a 60 line screen on 300 DPI printers and
  1208.     % an 85 line screen on 600 DPI printers.
  1209.     % However, we use a 106 line screen, which produces smoother-
  1210.     % looking shades but fewer of them (32 vs. 50).
  1211.     % 46 was suggested as a good frequency value for printers
  1212.     % between 200 and 400 DPI, so we use it for lower resolutions.
  1213.     % Imagesetters need even higher frequency screens.
  1214.    //systemdict /DITHERPPI known
  1215.     { DITHERPPI
  1216.     }
  1217.     { dup cvi 100 idiv 15 .min
  1218.        {//null 46 46 60 60 60 106 106 106 106 133 133 133 133 133 150}
  1219.       exch get
  1220.      }
  1221.    ifelse
  1222.    1 index 4.01 div .min    % at least a 4x4 cell
  1223.    45
  1224.     % The following screen algorithm is used by permission of the author.
  1225.     { 1 add 180 mul cos 1 0.08 add mul exch 2 add 180 mul cos 
  1226.       1 0.08 sub mul add 2 div % (C) 1989 Berthold K.P. Horn
  1227.     }
  1228.    bind
  1229.     % Determine whether we have lots of process colors.
  1230.     % If so, don't bother with color screening or gamma correction.
  1231.     % Also don't do gamma correction on very high-resolution devices.
  1232.     % (This should depend on dot gain, not resolution, but we don't
  1233.     % currently have a way to determine this.) Ignore missing components
  1234.         % (*Values = 1).
  1235.    currentdevice mark
  1236.      /RedValues 0 /GreenValues 0 /BlueValues 0 /GrayValues 0
  1237.    .dicttomark .getdeviceparams
  1238.    counttomark 2 idiv 1 sub
  1239.     { exch pop dup 1 le
  1240.        { pop }
  1241.        { exch dup 1 le
  1242.           { pop }
  1243.           { .min }
  1244.         ifelse
  1245.        }
  1246.       ifelse
  1247.     }
  1248.    repeat
  1249.    exch pop exch pop 32 lt 4 index 800 lt and 5 1 roll
  1250.     % Stack: doscreen dpi freq angle proc
  1251.     % Ghostscript currently doesn't use correct, per-plane halftones
  1252.     % unless setcolorscreen has been executed.  Since these are
  1253.     % computationally much more expensive than binary halftones,
  1254.     % we check to make sure they are really warranted, i.e., we have
  1255.     % a high-resolution CMYK device (i.e., not a display) with
  1256.     % fewer than 5 bits per plane (i.e., not a true-color device).
  1257.    4 -1 roll 150 ge
  1258.     { /setcolorscreen where
  1259.        { pop //systemdict /COLORSCREEN known
  1260.       { COLORSCREEN }
  1261.       { 3 index }
  1262.      ifelse
  1263.      dup false ne
  1264.       { 4 1 roll 3 copy 6 copy 13 -1 roll
  1265.     % For really high-quality screening on printers, we need to
  1266.     % give each plane its own screen angle.  Unfortunately,
  1267.     % this currently has very large space and time costs.
  1268.         true eq        % true => different angles,
  1269.                 % 0 => same angles
  1270.          { { 45 90 15 75 } { 3 1 roll exch pop 12 3 roll } forall
  1271.          }
  1272.         if //setcolorscreen
  1273.       }
  1274.       { pop //setscreen    % false => single binary screen
  1275.       }
  1276.      ifelse
  1277.        }
  1278.        { //setscreen        % setcolorscreen not known
  1279.        }
  1280.       ifelse
  1281.     }
  1282.     { //setscreen            % not high resolution
  1283.     }
  1284.    ifelse
  1285. } bind def
  1286. /.sethiresscreen {    % <dpi> .sethiresscreen 
  1287.   .sethireshalftone     % pushes true if a screen halftone used
  1288.             % Stack: doscree
  1289.   {
  1290.     % Set the transfer function to lighten up the grays.
  1291.     % We correct at the high end so that very light grays
  1292.     % don't disappear completely if they darken <1 screen pixel.
  1293.     % Parameter values closer to 1 are better for devices with
  1294.     % less dot spreading; lower values are better with more spreading.
  1295.     % The value 0.8 is a compromise that will probably please no one!
  1296.     %
  1297.     % Because of a bug in FrameMaker, we have to accept operands
  1298.     % outside the valid range of [0..1].
  1299.     {
  1300.       dup dup 0.0 gt exch 1.0 lt and
  1301.       {
  1302.         0.8 exp
  1303.         dup 0.998 lt   % 254.5 / 255
  1304.         {    % Keep at least one halftone dot if not saturated color
  1305.           .currentscreenlevels 1 sub dup 1 sub exch div
  1306.       .min
  1307.         }
  1308.         if
  1309.       }
  1310.       if
  1311.     }
  1312.   }
  1313.   {
  1314.      % Set the transfer function to the identity.
  1315.      0 array cvx     % Genoa CET won't accept a packed array!
  1316.   }
  1317.   ifelse
  1318.   settransfer
  1319.   /setstrokeadjust where
  1320.   { pop false setstrokeadjust }
  1321.   if
  1322.  
  1323.   % Increase fill adjustment so that we effectively use Adobe's
  1324.   % any-part-of-pixel rule.
  1325.   0.5 .setfilladjust
  1326. } bind def
  1327. % Set the default screen and BG/UCR.
  1328. /.setdefaultbgucr {
  1329.   systemdict /setblackgeneration known {
  1330.     { pop 0 } dup setblackgeneration setundercolorremoval
  1331.   } if
  1332. } bind def
  1333. /.useloresscreen {    % - .useloresscreen <bool>
  1334.     % Compute min(|dpi x|,|dpi y|) as the definition of the resolution.
  1335.   72 72 matrix defaultmatrix dtransform abs exch abs .min
  1336.   dup 150 lt //systemdict /DITHERPPI known not and
  1337. } bind def
  1338.  
  1339. % The following implementation uses LL2 extensions, but only in stopped
  1340. % contexts so that with LL1, the .set??reshalftone will be used.
  1341. %
  1342. %    - .getdefaulthalftone <halftonedict> true    if default found
  1343. %                  false            
  1344. /.getdefaulthalftone {
  1345.   % try the device to see if it has a default halftone
  1346.   { currentdevice /HalftoneDefault gsgetdeviceprop } stopped
  1347.   { pop pop false }        % no device property
  1348.   { dup type /dicttype eq { true } { pop false } ifelse }
  1349.   ifelse
  1350.   % stack: <halftonedict> true    if default found
  1351.   %         false          not found
  1352.   dup not
  1353.   { % device did not provide a default, try Resource
  1354.     pop { /Default /Halftone /findresource .systemvar exec } stopped 
  1355.     { pop pop false } { true } ifelse
  1356.   }
  1357.   if
  1358. } bind def
  1359.  
  1360. /.setdefaulthalftone {
  1361.   .getdefaulthalftone 
  1362.   { sethalftone }
  1363.   { % default not found
  1364.     .useloresscreen { .setloreshalftone } { .sethireshalftone pop } ifelse
  1365.   }
  1366.   ifelse
  1367. } bind def
  1368.  
  1369. /.setdefaultscreen {
  1370.   .useloresscreen { .setloresscreen } { .sethiresscreen } ifelse
  1371.   .setdefaultbgucr
  1372. } bind def
  1373.  
  1374. % Load basic color support
  1375. %% Replace 1 (gs_cspace.ps)
  1376. (gs_cspace.ps) runlibfile
  1377.  
  1378. (END BASIC COLOR) VMDEBUG
  1379.  
  1380. %% Replace 1 (gs_devcs.ps)
  1381. (gs_devcs.ps) runlibfile
  1382.  
  1383. (END LEVEL 1 COLOR) VMDEBUG
  1384.  
  1385. % Load image support
  1386. %% Replace 1 (gs_img.ps)
  1387. (gs_img.ps) runlibfile
  1388.  
  1389. (END IMAGE) VMDEBUG
  1390.  
  1391. % Load the initialization files for optional features.
  1392. %% Replace 4 INITFILES
  1393. systemdict /INITFILES known
  1394.  { INITFILES { dup runlibfile VMDEBUG } forall
  1395.  }
  1396. if
  1397.  
  1398. % If Level 2 (or higher) functionality is implemented, enable it now.
  1399. /.setlanguagelevel where {
  1400.   pop 2 .setlanguagelevel
  1401.     % If the resource machinery is loaded, fix up some things now.
  1402.   /.fixresources where { pop .fixresources } if
  1403. } if
  1404. /ll3dict where {
  1405.   pop 3 .setlanguagelevel
  1406. } if
  1407.  
  1408. (END INITFILES) VMDEBUG
  1409.  
  1410. % Create a null font.  This is the initial font.
  1411. 8 dict dup begin
  1412.   /FontMatrix [ 1 0 0 1 0 0 ] readonly def
  1413.   /FontType 3 def
  1414.   /FontName () def
  1415.   /Encoding StandardEncoding def
  1416.   /FontBBox { 0 0 0 0 } readonly def % executable is bogus, but customary ...
  1417.   /BuildChar { pop pop 0 0 setcharwidth } bind def
  1418.   /PaintType 0 def        % shouldn't be needed!
  1419. end
  1420. /NullFont exch definefont setfont
  1421.  
  1422. % Define NullFont as the font.
  1423. /NullFont currentfont def
  1424.  
  1425. % Load initial fonts from FONTPATH directories, Fontmap file,
  1426. % and/or .getccfont as appropriate.
  1427. .loadinitialfonts
  1428.  
  1429. % Remove NullFont from FontDirectory, so it can't be accessed by mistake.
  1430. /undefinefont where {
  1431.   pop /NullFont undefinefont
  1432. } {
  1433.   FontDirectory /NullFont .undef
  1434. } ifelse
  1435.  
  1436. (END FONTS) VMDEBUG
  1437.  
  1438. % Restore the real definition of runlibfile.
  1439. /runlibfile /.runlibfile load def
  1440. currentdict /.runlibfile .undef
  1441.  
  1442. % Bind all the operators defined as procedures.
  1443. /.bindoperators        % binds operators in currentdict
  1444.  { % Temporarily disable the typecheck error.
  1445.    errordict /typecheck 2 copy get
  1446.    errordict /typecheck { pop } put    % pop the command
  1447.    currentdict
  1448.     { dup type /operatortype eq
  1449.        { % This might be a real operator, so bind might cause a typecheck,
  1450.      % but we've made the error a no-op temporarily.
  1451.      .bind        % do a real bind even if NOBIND is set
  1452.        }
  1453.       if pop pop
  1454.     } forall
  1455.    put
  1456.  } def
  1457. NOBIND DELAYBIND or not { .bindoperators } if
  1458.  
  1459. % Establish a default environment.
  1460.  
  1461. defaultdevice
  1462. % The following line used to skip setting of page size and resolution if
  1463. % NODISPLAY was selected.  We think this was only to save time and memory,
  1464. % and it is a bad idea because it prevents setting the resolution in this
  1465. % situation, which pstoedit (among other programs) relies on.
  1466. %DISPLAYING not { setdevice (%END DISPLAYING) .skipeof } if
  1467. systemdict /DEVICEWIDTH known
  1468. systemdict /DEVICEHEIGHT known or
  1469. systemdict /DEVICEWIDTHPOINTS known or
  1470. systemdict /DEVICEHEIGHTPOINTS known or
  1471. systemdict /DEVICEXRESOLUTION known or
  1472. systemdict /DEVICEYRESOLUTION known or
  1473. systemdict /PAPERSIZE known or
  1474. not { (%END DEVICE) .skipeof } if
  1475. % Let DEVICE{WIDTH,HEIGHT}[POINTS] override PAPERSIZE.
  1476. systemdict /PAPERSIZE known
  1477. systemdict /DEVICEWIDTH known not and
  1478. systemdict /DEVICEHEIGHT known not and
  1479. systemdict /DEVICEWIDTHPOINTS known not and
  1480. systemdict /DEVICEHEIGHTPOINTS known not and
  1481.  {    % Convert the paper size to device dimensions.
  1482.    true statusdict /.pagetypenames get
  1483.     { PAPERSIZE eq
  1484.        { PAPERSIZE load
  1485.          dup 0 get /DEVICEWIDTHPOINTS exch def
  1486.          1 get /DEVICEHEIGHTPOINTS exch def
  1487.          pop false exit
  1488.        }
  1489.       if
  1490.     }
  1491.    forall
  1492.     { (Unknown paper size: ) print PAPERSIZE ==only (.) =
  1493.     }
  1494.    if
  1495.  }
  1496. if
  1497. % Adjust the device parameters per the command line.
  1498. % It is possible to specify resolution, pixel size, and page size;
  1499. % since any two of these determine the third, conflicts are possible.
  1500. % We simply pass them to .setdeviceparams and let it sort things out.
  1501.    mark /HWResolution //null /HWSize //null /PageSize //null .dicttomark
  1502.    .getdeviceparams .dicttomark begin
  1503.    mark
  1504.     % Check for resolution.
  1505.    /DEVICEXRESOLUTION where dup
  1506.     { exch pop HWResolution 0 DEVICEXRESOLUTION put }
  1507.    if
  1508.    /DEVICEYRESOLUTION where dup
  1509.     { exch pop HWResolution 1 DEVICEYRESOLUTION put }
  1510.    if
  1511.    or { /HWResolution HWResolution } if
  1512.     % Check for device sizes specified in pixels.
  1513.    /DEVICEWIDTH where dup
  1514.     { exch pop HWSize 0 DEVICEWIDTH put }
  1515.    if
  1516.    /DEVICEHEIGHT where dup
  1517.     { exch pop HWSize 1 DEVICEHEIGHT put }
  1518.    if
  1519.    or { /HWSize HWSize } if
  1520.     % Check for device sizes specified in points.
  1521.    /DEVICEWIDTHPOINTS where dup
  1522.     { exch pop PageSize 0 DEVICEWIDTHPOINTS put }
  1523.    if
  1524.    /DEVICEHEIGHTPOINTS where dup
  1525.     { exch pop PageSize 1 DEVICEHEIGHTPOINTS put }
  1526.    if
  1527.    or { /PageSize PageSize } if
  1528.     % Check whether any parameters were set.
  1529.    dup mark eq { pop } { defaultdevice putdeviceprops } ifelse
  1530.    end
  1531. %END DEVICE
  1532. % Set any device properties defined on the command line.
  1533. % If BufferSpace is defined but not MaxBitmap, set MaxBitmap to BufferSpace.
  1534. systemdict /BufferSpace known
  1535. systemdict /MaxBitmap known not and
  1536.  { systemdict /MaxBitmap BufferSpace put
  1537.  } if
  1538. dup getdeviceprops
  1539. counttomark 2 idiv
  1540.  { systemdict 2 index known
  1541.     { pop dup load counttomark 2 roll }
  1542.     { pop pop }
  1543.    ifelse
  1544.  } repeat
  1545. counttomark dup 0 ne
  1546.  { 2 add -1 roll putdeviceprops }
  1547.  { pop pop }
  1548. ifelse
  1549. % If the initial device parameters are invalid, the setdevice may fail.
  1550. % Trap this and produce a reasonable error message.
  1551. { setdevice }        % does an erasepage
  1552. DEBUG { exec false } { .internalstopped } ifelse {
  1553.   (**** Unable to open the initial device, quitting.) = flush 1 .quit
  1554. } if
  1555.  
  1556. % If the media size is fixed, update the current page device dictionary.
  1557. FIXEDMEDIA
  1558. dup { pop systemdict /.currentpagedevice known } if
  1559. dup { pop .currentpagedevice exch pop } if
  1560. not { (%END MEDIA) .skipeof } if
  1561. currentpagedevice dup length dict .copydict
  1562. dup /Policies
  1563.     % Stack: <pagedevice> <pagedevice> /Policies
  1564. 1 index /InputAttributes
  1565. 2 copy get dup length dict .copydict
  1566.     % Stack: <pagedevice> <pagedevice> /Policies <pagedevice>
  1567.     %   /InputAttributes <inputattrs'>
  1568. dup 0 2 copy get dup length dict .copydict
  1569.     % Stack: <pagedevice> <pagedevice> /Policies <pagedevice>
  1570.     %   /InputAttributes <inputattrs'> <inputattrs'> 0 <attrs0'>
  1571. dup /PageSize 7 index /PageSize get
  1572. put                % PageSize in 0
  1573. put                % 0 in InputAttributes
  1574. put                % InputAttributes in pagedevice
  1575. % Also change the page size policy so we don't get an error.
  1576.     % Stack: <pagedevice> <pagedevice> /Policies
  1577. 2 copy get dup length dict .copydict
  1578.     % Stack: <pagedevice> <pagedevice> /Policies <policies'>
  1579. dup /PageSize 7 put        % PageSize in Policies
  1580. put                % Policies in pagedevice
  1581. .setpagedevice
  1582. %END MEDIA
  1583. %END DISPLAYING
  1584.  
  1585. (END DEVICE) VMDEBUG
  1586.  
  1587. % Establish a default upper limit in the character cache,
  1588. % namely, enough room for a 18-point character at the resolution
  1589. % of the default device, or for a character consuming 1% of the
  1590. % maximum cache size, whichever is larger.
  1591. mark
  1592.     % Compute limit based on character size.
  1593.   18 dup dtransform
  1594.   exch abs cvi 31 add 32 idiv 4 mul    % X raster
  1595.   exch abs cvi mul        % Y
  1596.     % Compute limit based on allocated space.
  1597.   cachestatus pop pop pop pop pop exch pop 0.01 mul cvi
  1598.   .max dup 10 idiv exch
  1599. setcacheparams
  1600. % Conditionally disable the character cache.
  1601. NOCACHE { 0 setcachelimit } if
  1602.  
  1603. (END CONFIG) VMDEBUG
  1604.  
  1605. % Initialize graphics.
  1606.  
  1607. .setdefaultscreen
  1608. initgraphics
  1609.  
  1610. % The interpreter relies on there being at least 2 entries
  1611. % on the graphics stack.  Establish the second one now.
  1612. gsave
  1613.  
  1614. % Define some control sequences as no-ops.
  1615. % This is a hack to get around problems
  1616. % in some common PostScript-generating applications.
  1617. <04> cvn { } def        % Apple job separator
  1618. <0404> cvn { } def        % two of the same
  1619. <1b> cvn { } def        % MS Windows LaserJet 4 prologue
  1620.                 % (UEL = ESC %-12345X)
  1621. <1b45> cvn { } def        % PJL reset prologue (ESC E)
  1622. <1b451b> cvn { } def        % PJL reset epilogue (ESC E + UEL)
  1623. <041b> cvn { } def        % MS Windows LaserJet 4 epilogue (^D + UEL)
  1624. (\001M) cvn            % TBCP initiator
  1625.  { currentfile /TBCPDecode filter cvx exec
  1626.  } bind def
  1627. /@PJL                % H-P job control
  1628.  { currentfile //=string readline { pop } if
  1629.  } bind def
  1630.  
  1631. % Install the EPS handler if needed
  1632. systemdict /EPSBoundingBoxInit known { EPSBoundingBoxInit } if
  1633.  
  1634. % If we want a "safer" system, disable some obvious ways to cause havoc.
  1635. .currentglobal true .setglobal
  1636. /SAFETY 2 dict
  1637.   dup /safe false put
  1638.   dup /tempfiles 10 dict readonly put
  1639. readonly def
  1640. .setglobal
  1641.  
  1642. % Convert a path name into a string suitable for filenameforall
  1643. % For example: (a\\b*?c) to (a\\\\b\\*\\?c)
  1644. /.makepathtemplate {    % str1 -- str2
  1645.    dup length dup add string 0    % result string up to twice the size
  1646.    0 1 4 index length 1 sub {
  1647.      3 index exch get
  1648.      dup 92 eq {        % \ -> \\
  1649.         2 index 2 index 92
  1650.         put
  1651.         exch 1 add exch
  1652.      } 
  1653.      if
  1654.      dup 42 eq {        % * -> \*
  1655.         2 index 2 index 92
  1656.         put
  1657.         exch 1 add exch
  1658.      } 
  1659.      if
  1660.      dup 63 eq {        % ? -> \?
  1661.         2 index 2 index 92
  1662.         put
  1663.         exch 1 add exch
  1664.      } 
  1665.      if
  1666.      2 index 2 index 3 -1 roll put 1 add
  1667.    } for
  1668.    0 exch getinterval exch pop
  1669. } bind def
  1670.  
  1671. /.locksafe {
  1672.   SAFETY /safe get not {
  1673.     <<
  1674.       /PermitFileReading [
  1675.         currentuserparams /PermitFileReading get aload pop
  1676.     { .makepathtemplate 
  1677.           dup .filenamedirseparator concatstrings (*) concatstrings 
  1678.       exch        % put string below this procedure
  1679.     }
  1680.         /LIBPATH .systemvar { 1 index exec } forall
  1681.         /FONTPATH .systemvar  { 1 index exec } forall
  1682.     currentsystemparams /GenericResourceDir get 1 index exec 
  1683.     currentsystemparams /FontResourceDir get exch exec
  1684.       ]
  1685.       /LockFilePermissions true
  1686.     >> setuserparams
  1687.   }
  1688.   if
  1689.   % setpagedevice has the side effect of clearing the page, but
  1690.   % we will just document that. Using setpagedevice keeps the device
  1691.   % properties and pagedevice .LockSafetyParams in agreement even
  1692.   % after a restore that changes the value to false.
  1693.   currentglobal currentpagedevice gcheck setglobal % use correct VM space
  1694.   << /.LockSafetyParams true >> setpagedevice
  1695.   setglobal
  1696.   //SAFETY /safe //true .forceput % overrides readonly
  1697. } .bind executeonly odef
  1698.  
  1699. /.setsafe
  1700. {
  1701.   SAFETY /safe get not {
  1702.     <<
  1703.       /PermitFileReading [ ]
  1704.       /PermitFileWriting [ ]
  1705.       /PermitFileControl [ ]
  1706.     >> setuserparams
  1707.   }
  1708.   if
  1709.   .locksafe
  1710. } .bind executeonly odef
  1711.  
  1712. /deletefile {
  1713.   count 1 lt {
  1714.     //deletefile /stackunderflow signalerror
  1715.   }
  1716.   if
  1717.   dup { deletefile } stopped {
  1718.     pop //deletefile $error /errorname get signalerror
  1719.   } {
  1720.     % deletefile succeeded. Remove from tempfile list if present
  1721.     //SAFETY /tempfiles get exch cvn 2 copy known {
  1722.       .forceundef
  1723.     } {
  1724.       pop pop
  1725.     }
  1726.     ifelse
  1727.   }
  1728.   ifelse
  1729. } .bind executeonly odef
  1730.  
  1731. % If a file is opened with .tempfile with SAFER not (yet) set,
  1732. % the file can be deleted later, even if SAFER is set.
  1733. /.tempfile {
  1734.   .tempfile    % filename file
  1735.   //SAFETY /tempfiles get 2 index true .forceput
  1736. } .bind executeonly odef
  1737.  
  1738. % If we are running in SAFER mode, lock things down
  1739. SAFER { .setsafe } if
  1740.  
  1741. % If we delayed binding, make it possible to do it later.
  1742. /.bindnow {
  1743.   //systemdict begin .bindoperators end
  1744.   % Temporarily disable the typecheck error.
  1745.   errordict /typecheck 2 copy get
  1746.   errordict /typecheck { pop } put    % pop the command
  1747.   0 1 .delaycount 1 sub { .delaybind exch get .bind pop } for
  1748.   //systemdict /.delaybind {} .forceput    % reclaim the space
  1749.   //systemdict /.bindnow .forceundef    % ditto
  1750.   put
  1751.   //systemdict /.forcedef .forceundef        % remove temptation
  1752.   //systemdict /.forceput .forceundef        % ditto
  1753.   //systemdict /.forceundef .forceundef        % ditto
  1754. } .bind odef
  1755.  
  1756. % Turn off array packing, since some PostScript code assumes that
  1757. % procedures are writable.
  1758. false setpacking
  1759.  
  1760. (END INIT) VMDEBUG
  1761.  
  1762. /.currentuserparams where {
  1763.   pop
  1764.     % Remove real user params from psuserparams.
  1765.   mark .currentuserparams counttomark 2 idiv {
  1766.     pop psuserparams exch undef
  1767.   } repeat pop
  1768.     % Update the copy of the user parameters.
  1769.   mark .currentuserparams counttomark 2 idiv {
  1770.     userparams 3 1 roll .forceput    % userparams is read-only
  1771.   } repeat pop
  1772.     % Turn on idiom recognition, if available.
  1773.   currentuserparams /IdiomRecognition known {
  1774.     /IdiomRecognition true .definepsuserparam
  1775.   } if
  1776.   psuserparams readonly pop
  1777.   systemdict /.definepsuserparam undef
  1778.     % Save a copy of userparams for use with save/restore
  1779.     % (and, if implemented, context switching).
  1780.   .currentglobal false .setglobal
  1781.      mark userparams { } forall .dicttomark readonly
  1782.      /userparams exch .forcedef        % systemdict is read-only
  1783.   .setglobal
  1784. } if
  1785. /.currentsystemparams where {
  1786.   pop
  1787.     % Remove real system params from pssystemparams.
  1788.   mark .currentsystemparams counttomark 2 idiv {
  1789.     pop pssystemparams exch .forceundef
  1790.   } repeat pop
  1791. } if
  1792.  
  1793. % Conditionally turn image interpolation on or off.
  1794. currentdict /INTERPOLATE known not { (%END INTERPOLATE) .skipeof } if
  1795.  
  1796. /.interpolate {
  1797.   dup /Interpolate .knownget not { //false } if
  1798.   /INTERPOLATE .systemvar ne {
  1799.     dup gcheck .currentglobal exch .setglobal
  1800.     exch dup length dict copy
  1801.     dup /Interpolate /INTERPOLATE .systemvar put
  1802.     exch .setglobal
  1803.   } if
  1804. } bind odef
  1805.  
  1806. /colorimage
  1807.   { /INTERPOLATE .systemvar
  1808.       { .currentglobal                    % w h bit [] {}...{} multi ncomp glob
  1809.         //false .setglobal
  1810.         9 dict begin                      % w h bit [] {}...{} multi ncomp glob
  1811.         2 index { 1 index 7 add } { 8 } ifelse
  1812.         copy gsave pop                    % preserve the arguments
  1813.         { 0 /DeviceGray 0 /DeviceRGB /DeviceCMYK }
  1814.         1 index get setcolorspace         % ... glob w h bit [] {}...{} multi ncomp
  1815.         {0 1 0 1 0 1 0 1}
  1816.         1 index 2 mul 0 exch              % ... glob w h bit [] {}...{} multi ncomp {0 1 ...} 0 2*ncomp
  1817.         getinterval /Decode exch def      % ... glob w h bit [] {}...{} multi ncomp
  1818.         exch dup                          % ... glob w h bit [] {}...{} ncomp multi multi
  1819.         /MultipleDataSources exch def     % ... glob w h bit [] {}...{} ncomp multi
  1820.         { array astore} { pop } ifelse    % ... glob w h bit [] [{}...{}]
  1821.         /DataSource exch def              % ... glob w h bit []
  1822.         /ImageMatrix exch def             % ... glob w h bit
  1823.         /BitsPerComponent exch def        % ... glob w h
  1824.         /Height exch def                  % ... glob w
  1825.         /Width exch def                   % ... glob 
  1826.         /ImageType 1 def
  1827.         /Interpolate //true def
  1828.         .setglobal currentdict end        % ... <<>>
  1829.         image grestore
  1830.         exch { 4 add } { 6 } ifelse
  1831.         { pop } repeat                    % -
  1832.       }
  1833.       { colorimage
  1834.       }
  1835.     ifelse
  1836.   } bind odef
  1837.  
  1838. /image
  1839.   { dup type /dicttype eq
  1840.       { dup /ImageType get 3 eq
  1841.           { .currentglobal //false .setglobal exch
  1842.             dup length dict copy begin .setglobal 
  1843.             /DataDict DataDict .interpolate def
  1844.             /MaskDict MaskDict .interpolate def
  1845.             currentdict end
  1846.           }
  1847.           { .interpolate 
  1848.           }
  1849.         ifelse
  1850.         image
  1851.       }
  1852.       { /INTERPOLATE .systemvar
  1853.           { .currentglobal //false .setglobal
  1854.             8 dict begin .setglobal
  1855.             /ImageType 1 def
  1856.             /DataSource 1 index def
  1857.             /ImageMatrix 2 index def
  1858.             /BitsPerComponent 3 index def
  1859.             /Decode {0 1} def
  1860.             /Height 4 index def
  1861.             /Width 5 index def
  1862.             /Interpolate //true def
  1863.             currentdict end
  1864.             gsave /DeviceGray setcolorspace image grestore
  1865.             5 { pop } repeat
  1866.           }
  1867.           { image
  1868.           }
  1869.         ifelse
  1870.       }
  1871.     ifelse
  1872.   } bind odef
  1873.  
  1874. /imagemask {
  1875.   dup type /dicttype eq {
  1876.     .interpolate imagemask
  1877.   } {
  1878.     /INTERPOLATE .systemvar {
  1879.       .currentglobal //false .setglobal
  1880.       8 dict begin .setglobal
  1881.       /ImageType 1 def
  1882.       /DataSource 1 index def
  1883.       /ImageMatrix 2 index def
  1884.       /BitsPerComponent 1 def
  1885.       2 index { {1 0} } { {0 1} } ifelse /Decode exch def
  1886.       /Height 4 index def
  1887.       /Width 5 index def
  1888.       /Interpolate //true def
  1889.       currentdict end imagemask 5 { pop } repeat
  1890.     } {
  1891.       imagemask
  1892.     } ifelse
  1893.   } ifelse
  1894. } bind odef
  1895.  
  1896. currentdict /.interpolate undef
  1897.  
  1898. %END INTERPOLATE
  1899.  
  1900. % Establish local VM as the default.
  1901. false /setglobal where { pop setglobal } { .setglobal } ifelse
  1902. $error /.nosetlocal false put
  1903.  
  1904. (END GLOBAL) VMDEBUG
  1905.  
  1906. /.savelocalstate where {
  1907.     % If we might create new contexts, save away copies of all dictionaries
  1908.     % referenced from systemdict that are stored in local VM,
  1909.     % and also save a copy of the initial gstate.
  1910.   pop .savelocalstate
  1911. } {
  1912.     % If we're *not* running in a multi-context system and FAKEFONTS is
  1913.     % defined, add the fake fonts to LocalFontDirectory.
  1914.   .definefakefonts    % current VM is local
  1915. } ifelse
  1916.  
  1917. % Remove systemdict entries for things that have been bound in where used
  1918. % and that shouldn't be accessible by name, and close up systemdict.
  1919. currentdict /filterdict .undef
  1920. currentdict /.cidfonttypes .undef
  1921. currentdict /.colorrenderingtypes .undef
  1922. currentdict /.formtypes .undef
  1923. currentdict /.halftonetypes .undef
  1924. currentdict /.imagetypes .undef
  1925. currentdict /.imagemasktypes .undef
  1926. currentdict /.patterntypes .undef
  1927. currentdict /.shadingtypes .undef
  1928. currentdict /.wheredict .undef
  1929. end
  1930.  
  1931. % Clean up VM, and enable GC.
  1932. /vmreclaim where
  1933.  { pop NOGC not { 2 vmreclaim 0 vmreclaim } if
  1934.  } if
  1935. DELAYBIND not {
  1936.   systemdict /.forcedef .undef        % remove temptation
  1937.   systemdict /.forceput .undef        % ditto
  1938.   systemdict /.forceundef .undef    % ditto
  1939. } if
  1940. WRITESYSTEMDICT not { systemdict readonly pop } if
  1941.  
  1942. (END GC) VMDEBUG
  1943.  
  1944. % The Adobe AGM_Core used by Illustrator 9 has some code that breaks
  1945. % if the 'product' is not (Adobe PostScript Parser). A bug has been
  1946. % submitted to Adobe since this also fails with Acrobat Distiller.
  1947. % As a temporary work around, the following HACK will work for
  1948. % devices without spot color support. Once Ghostscript can
  1949. % support DeviceN and spot color separations this will need to
  1950. % be 'true' in some cases.
  1951. userdict /AGM_preserve_spots false put
  1952.  
  1953. % The interpreter will run the initial procedure (start).
  1954.